package mall.core.web;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author xf07b1
 * @wechat xf07b1
 * @description 后台管理Controller模板。
 * 跳转页面用view*，例如viewList，viewEdit；viewCreate
 * 具体操作用create，例如update；create
 */
public abstract class AbstractAdminController extends Controller {
    /**
     * 新增
     */
    public void create(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        redirect("/admin/*?method=viewList", request, response);
    }

    /**
     * 删除
     */
    public void remove(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        redirect("/admin/*?method=viewList", request, response);
    }

    /**
     * 修改
     */
    public void update(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        redirect("/admin/*?method=viewList", request, response);
    }

    /**
     * 查询
     */
    public void query(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        forward("/admin/*/list", request, response);
    }
    /**
     * 访问列表页面
     */
    public void viewList(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        forward("/admin/*/list", request, response);
    }

    /**
     * 访问新增页面
     */
    public void viewCreate(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        forward("/admin/*/create", request, response);
    }

    /**
     * 访问编辑页面
     */
    public void viewEdit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        forward("/admin/*/edit", request, response);
    }
}
